package Controllers;

import Models.LoginModel;
import Models.PrinterModel;
import PrinterSource.PrinterManager;
import PrinterSource.QueryHandler;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.log4j.Logger;

public class MainMenuController extends HttpServlet {
    

    public void doPost( HttpServletRequest request, 
                      HttpServletResponse response) 
                      throws IOException, ServletException {

        QueryHandler manager = new QueryHandler();
        String viewpage = request.getParameter("MainChoice");

        if("viewprinters".equals(viewpage.toLowerCase())){

            List<String> printeraddr = QueryHandler.get_printers();
            request.setAttribute("PrinterModels", printeraddr);
            RequestDispatcher view = request.getRequestDispatcher("PrinterDisplay.jsp");
            view.forward(request, response);
        }
        
        else if("networkstatus".equals(viewpage.toLowerCase())){

            List<String> models= QueryHandler.get_printers();
            request.setAttribute("PrinterModels", models);
            RequestDispatcher view = request.getRequestDispatcher("NetworkStatus.jsp");
            view.forward(request, response);
        }
        
        else if("about".equals(viewpage.toLowerCase())){

            RequestDispatcher view = request.getRequestDispatcher("About.jsp");
            view.forward(request, response);

        }
        else if("systemlog".equals(viewpage.toLowerCase())){

            RequestDispatcher view = request.getRequestDispatcher("SystemLog.jsp");
            view.forward(request, response);

        }
        else{
            RequestDispatcher view =request.getRequestDispatcher("main.jsp");
            view.forward(request, response);
        }

      
    }
    
/*    public List<PrinterModel> get_models(){
        PrinterManager manager = new PrinterManager();
        
        return manager.models;
 
    }*/
}
